<template>
	<!-- 积分提现 -->
	<view>
		<u-navbar title="提现" :autoBack="true" :placeholder="true"></u-navbar>
		<view class="minBox">
			<view class="title">提现金额</view>
			<view class="moneyBox">
				<view class="symbol">￥</view>
				<input type="number" placeholder="请输入提现金额" v-model="money"
					placeholder-style=" color: rgba(0,0,0,0.26);font-size: 24rpx;margin-top:10rpx">
			</view>
			<view class="tipsBox">
				可提现金额 ¥{{maxMoney}}
				<view class="all" @click="fullWithdrawal">全部提现</view>
			</view>
			<view class="collectionTitle">收款信息</view>
			<view class="photoBox">
				<ImgUpload @callback="callback1" maxCount="10" />
			</view>
			<view class="collectionTitle">提现说明</view>
			<view class="desc">
				<u-parse :content="content"></u-parse>
			</view>
		</view>
		<view class="btnBox">
			<view class="cancel" @click="cancel">取消</view>
			<view class="determine" @click="affirm">确认提现</view>
		</view>
	</view>
</template>

<script>
	import ImgUpload from '@/components/ImgUpload/ImgUpload.vue'
	export default {
		data() {
			return {
				money: "", //提现金额
				maxMoney: null, //可提现金额
				photoList: [],
				content: "", //富文本
			};
		},
		components: {
			ImgUpload
		},
		onLoad(option) {
			this.maxMoney = option.money
			this.getdrawdet()
		},
		methods: {
			// 取消
			cancel() {
				uni.navigateBack()
			},
			// 确认
			async affirm() {
				if (this.money === "" || this.photoList.length === 0) {
					this.$u.toast('请补全提现金额或收款码')
				} else {
					let {
						code,
						msg
					} = await this.$api.posit({
						money: this.money,
						mocode: this.photoList.map(item => item.url).join(',')
					})
					this.$u.toast(msg)
					if (code === 1) {
						setTimeout(() => {
							uni.navigateBack()
						}, 1500)
					}
				}

			},
			// 上传图片成功回调
			callback1(e) {
				this.photoList = e
				console.log(e);
			},
			//全部提现
			fullWithdrawal() {
				this.money = this.maxMoney
			},
			// 获取提现说明
			async getdrawdet() {
				let res = await this.$api.getdrawdet()
				this.content = res.data
			}
		},
	}
</script>
<style>
	page {
		background: #fff;
	}
</style>
<style lang="scss" scoped>
	.u-navbar__content__title {
		color: rgba(0, 0, 0, 0.8);
		font-size: 32rpx;
		font-weight: 700;
	}



	.minBox {
		padding: 32rpx;

		.title {
			margin-bottom: 36rpx;
			color: rgba(0, 0, 0, 0.8);
			font-size: 28rpx;
			font-weight: 700;
		}

		.moneyBox {
			display: flex;
			align-items: center;

			.symbol {
				margin: 20rpx 16rpx 0 0;
				color: rgba(0, 0, 0, 0.26);
				font-size: 28rpx;
			}

			input {
				color: rgba(0, 0, 0, 0.8);
				font-size: 64rpx;
				font-weight: 700;
				height: 55rpx;
			}
		}

		.tipsBox {
			display: flex;
			align-items: center;
			color: rgba(0, 0, 0, 0.26);
			font-size: 24rpx;
			margin: 34rpx 0 56rpx 0;

			.all {
				margin-left: 16rpx;
				color: rgba(128, 110, 254, 1);
				font-size: 24rpx;
			}
		}

		.collectionTitle {
			color: rgba(0, 0, 0, 0.8);
			font-size: 28rpx;
			font-weight: 700;
			margin: 32rpx 0 16rpx 0;
		}

		.photoBox {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			image {
				width: 218rpx;
				height: 218rpx;
			}
		}

		.desc {
			color: rgba(0, 0, 0, 0.55);
			font-size: 24rpx;
		}
	}

	.btnBox {
		position: fixed;
		left: 0;
		bottom: 68rpx;
		display: flex;
		justify-content: space-between;
		width: 100%;
		padding: 0 32rpx;
		box-sizing: border-box;

		.cancel {
			display: flex;
			justify-content: center;
			align-items: center;
			width: 328rpx;
			height: 88rpx;
			color: rgba(0, 0, 0, 0.8);
			font-size: 32rpx;
			font-weight: 700;
			border-radius: 600rpx;
			background: rgba(248, 249, 254, 1);
		}

		.determine {
			display: flex;
			justify-content: center;
			align-items: center;
			color: rgba(255, 255, 255, 1);
			font-size: 32rpx;
			font-weight: 500;
			width: 328rpx;
			height: 88rpx;
			border-radius: 600rpx;
			opacity: 1;
			background: rgba(128, 110, 254, 1);
		}
	}
</style>
